<%@page contentType="text/html;charset=UTF-8"%>
<%@include file="/common/commonTag.jsp"%>
<html>
	<head>
		<title>员工管理</title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" href="${path}/css/backsys/ctx.css">
		<script type="text/javascript" src="${path}/js/jquery.js"></script>
		<script type="text/javascript" src="${path}/js/backsys/sysutil.js"></script>
		<script language="javascript" type="text/javascript" src="${path}/webutil/DateUtil/WdatePicker.js"></script>
		
		<script type="text/javascript">
			//设置离职
			function leave(empNo) {
				var retVal = window.showModalDialog("${path}/supersystem/oa/hr/leaveExplain.jsp?empNo="+empNo,"_blank","dialogHeight:352px;dialogWidth:500px");
			
				if(retVal != undefined) {
					var params = {"emp.empNo":retVal.empNo,"emp.dimissionMsg.DimissionDate":retVal.dimissionDate,"emp.dimissionMsg.DimissionCause":retVal.dimissionCause} ;
					var url = "${path}/empJson!leaveEmployee.action" ;
	
					$.post(url,params,function(data) {
						var result = eval('('+data+')') ;
						if(result.flag == true) {
							alert("该员工以标示为离职状态") ;
							$("#leave"+empNo).parent().html("<span  class='fontRedW'>离职</span>") ;
							
						} else {
							alert("标示为离职状态失败") ;
						}
					});
				}
			}
			//分配权限
			function setPrivilege(empNo,currentPage) {
				window.location.href="${path}/privilegeEmp!loadRoleAndRes.action?emp.empNo="+empNo+"&currentPage="+currentPage ;
			}
			//显示个人信息
			function showBySelf(empNo) {
				window.open("${path}/oa/hr/emp!getByIdEmployee.action?emp.empNo="+empNo+"&baseform.type=showEmp", "_blank", "width=300,height=300") ;
			}
			//修改员工信息
			$(function() {
				var r = $("input[type=radio]") ;
				r.click(function() {
					if(window.confirm("确定修改员工信息吗？")) {
						window.location="${path}/oa/hr/emp!getByIdEmployee.action?emp.empNo="+$(this).val()+"&currentPage=${pageView.currentPage}&baseform.type=modifyEmp";
					}
				});
			});
			//设置卡信息
			function setCard(empNoCardId) {
				window.open("${path}/oa/hr/empCard!loadEmpCard.action?EmpNocardId="+empNoCardId, "_blank", "width=300,height=300") ;
			}
		</script>
	</head>
	<body>
		<div class="ctx">
			
			<table width="100%" class="blockTable">
				<tr>
					<td>
						<div style="float:left;">
							<a href="${path}/oa/hr/emp!regEmployeeUI.action?baseform.type=orgUI" class="zPushBtn"><img src="${path}/images/icon003a2.gif"/><b>新建</b></a>
							<a href="#" class="zPushBtn"><img src="${path}/images/icon003a4.gif"/><b>编辑</b></a>
							<a href="#" class="zPushBtn"><img src="${path}/images/icon003a13.gif"/><b>发布</b></a>
							<a href="#" class="zPushBtn"><img src="${path}/images/icon403a3.gif"/><b>预览</b></a>
							<a href="#" class="zPushBtn"><img src="${path}/images/icon003a12.gif"/><b>复制</b></a>
							<a href="#" class="zPushBtn"><img src="${path}/images/icon003a7.gif"/><b>转移</b></a>
							<a href="#" class="zPushBtn"><img src="${path}/images/icon400a4.gif"/><b>排序</b></a>
							<a href="#" class="zPushBtn"><img src="${path}/images/icon003a3.gif"/><b>删除</b></a>
						</div>
					</td>
				</tr>
				<tr>
					<td> 
						<div style="float:left;font-size: 12px;text-align:left;">
							<span><input type="text" class="Wdate" value="<fmt:formatDate value="${empform.startDate}" pattern="yyyy-MM-dd"/>" readonly="readonly" onClick="WdatePicker()" size="14"/></span>
							<span>至</span>
							
							<span><input type="text" value="<fmt:formatDate value="${empform.endDate}" pattern="yyyy-MM-dd"/>" onchange="findbydate('${path}/oa/hr/emp!managerEmployee.action?empform.startDate=#&empform.endDate=#')" class="Wdate" readonly="readonly" onClick="WdatePicker()" size="14"/></span>
							&nbsp;
							<span>关键词:</span>
							<span><input type="text" id="keywork" value="${empform.keyword}"/></span>
							<span>
								<a href="javascript:void(0);" onclick="findbykeyword('${path}/oa/hr/emp!managerEmployee.action?empform.keyword=')" class="button"><b>&nbsp;查询&nbsp;</b></a>
							</span>
						</div>
					</td>
				</tr>
				
				
				<tr>
					<td>
						<table class="dataTable" width="100%">
							<tr class="dataTableHead">
								<td width="6%" align="center">序号</td> 
								<td width="6%">修改</td> 
								<td width="6%">其他</td> 
								<td>编号</td>
								<td>用户账号</td>
								<td>真实姓名</td>
								<td>卡片信息</td>
								<td>在职状态</td>
								<td>修改权限</td>
							</tr>  
							
							<c:choose>
								<c:when test="${empty pageView.records}">
									<tr class="dataTableBody">
										<td align="center" colspan="12" height="50">无法找到相关数据!!!</td>
									</tr>
								</c:when>
								<c:otherwise>
									<c:forEach var="emp" items="${pageView.records}" varStatus="s">
										<tr class="dataTableBody">
											<td align="center">${s.count}</td>
											<td align="center"><input type="radio" name="modify" value="${emp.empNo}"/></td>
											<td><input type="checkbox" name="checkbox" value="${emp.empNo}"/></td>
											<td>${emp.empNo}</td>
											<td>${emp.empAccount.account}</td>
											<td><a href="javascript:showBySelf('${emp.empNo}');">${emp.empRealname}</a></td> 
											<td><a href="javascript:setCard('${emp.empNo},${emp.empCard.id}')">设置卡片信息</a></td>
											<td>
												<c:choose>
													<c:when test="${emp.visible eq true}">
														<a href="javascript:leave('${emp.empNo}');" id="leave${emp.empNo}">标示为离职</a>
													</c:when>
													<c:otherwise>
														<span  class="fontRedW">离职</span>
													</c:otherwise>
												</c:choose>
											</td>
											<td>
												<c:choose>
													<c:when test="${emp.visible eq true}">
														<a href="javascript:setPrivilege('${emp.empNo}','${pageView.currentPage}');">分配权限</a>
													</c:when>
													<c:otherwise>
														<span>分配权限</span>
													</c:otherwise>
												</c:choose>
											
											</td>
										</tr>
									</c:forEach>
								</c:otherwise>
							</c:choose>
							
							<tr class="dataTableBottom">
								<td colspan="12">
									<jsp:include page="/common/fenye.jsp">
										<jsp:param value="/oa/hr/emp!managerEmployee.action" name="action"/>
									</jsp:include>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
	</body>
</html>
